
#include "StdAfx.h"
#include "DBStatement.h"
#include <stdarg.h>

#ifdef WIN32
#include <tchar.h>
#endif

DBStatement::DBStatement( DBSession* session ){
	session_ = session;
}

DBStatement::~DBStatement(){
	session_ = 0;
}

void DBStatement::reset(){	
	memset( sql_, 0, DEF_SQL_LEN );
}

int DBStatement::set_sql( char* sql_statement, ... ){
	if(! sql_statement )
		return DEFAULT_FAIL;

	memset( sql_, 0, sizeof( char ) * DEF_SQL_LEN );
	
	va_list	vaList;
	va_start( vaList, sql_statement );

#ifdef WIN32
	_vsntprintf( sql_, DEF_SQL_LEN, (const char *)sql_statement, vaList );
#else
	vsnprintf( sql_, DEF_SQL_LEN, (const char *)sql_statement, vaList );
#endif

	va_end( vaList );

	return DEFAULT_SUCCESS;
}
